﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TuxedoLib;

namespace SpaceSquirrel
{
	public class VictorySequenceScene : GameSceneBase
	{
		private PlayScene bg;
		private Image[] images;
		private int counter;

		public VictorySequenceScene(PlayScene bg)
			: base()
		{
			this.bg = bg;

			this.images = new Image[] {
				ImageLibrary.GetImage("slides/close1.png"),
				ImageLibrary.GetImage("slides/close2.png")
			};
			
			this.counter = 0;
		}

		public override void ProcessInput(List<MyEvent> events, Dictionary<string, bool> pressedActions)
		{
		}

		public override void Update()
		{
			JukeBox.Pause();
			this.counter++;
		}

		public override void Render(TuxedoLib.Image screen, int renderCounter)
		{
			screen.Fill(0, 0, 0);
			Image img;
			if (this.counter < 60)
			{
				img = this.images[0];
			}
			else if (this.counter > 120)
			{
				img = this.images[1];
			}
			else
			{
				img = this.images[this.counter & 1];
			}

			if (this.counter == 60)
			{
				SoundManager.PlayNoise("screen_shaking");
			}

			if (this.counter == 150)
			{
				this.Next = new DialogScene(this, "CloseDialog", false, true, true);
				this.counter++;
			}

			if (this.counter == 160)
			{
				this.Next = new CreditsScene();
			}

			screen.Blit(img, 0, 16);
		}
	}
}
